package com.qf.demo;

import com.qf.dao.StudentDaoImpl;
import com.qf.entity.Student;
import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/*
杨威
2021/9/6
15:36
*/
public class TestStudentDao {
    @Test
    public void insertTest()throws Exception{
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormat.parse("1995-01-16");
        Student student=new Student("sansi","女","18202429958",parse,"wei@qq.com","beijing",2);
        StudentDaoImpl studentDao=new StudentDaoImpl();
        int insert = studentDao.insert(student);
    }
    @Test
    public void updateTest(){
        try {
            SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
            Date parse = simpleDateFormat.parse("1995-01-16");
            Student student=new Student(21,"weiweiwei","男","18202429958",parse,"wei@qq.com","beijing",2);
            StudentDaoImpl studentDao=new StudentDaoImpl();
            int update = studentDao.update(student);
            System.out.println("update = " + update);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    @Test
    public void deleteTest(){
        StudentDaoImpl studentDao=new StudentDaoImpl();
        int delete = studentDao.delete(21);
        System.out.println("delete = " + delete);
    }
    @Test
    public void TestSelectOne(){
        StudentDaoImpl studentDao=new StudentDaoImpl();
        Student student = studentDao.selectOne(2);
        System.out.println("student = " + student);
    }
    @Test
    public void TestSelectAll(){
        StudentDaoImpl studentDao=new StudentDaoImpl();
        List<Student> studentList = studentDao.selectAll();
        studentList.forEach(System.out::println);
    }
}
